package com.xkcyy.study.mvc.controller;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.Max;
import java.util.HashMap;
import java.util.Map;

/**
 * UserController
 *
 * @author yuand
 * @date 2021/6/14
 **/
@RestController
@RequestMapping("/user/")
@Validated
public class UserController {
    @GetMapping
    public Object getName(HttpServletRequest request, @Max(10000) @RequestParam(required = false) String name) {
        return "123";
    }
//
//    @GetMapping("getName")
//    public String getName2(RedirectAttributes attributes) {
//        attributes.addAttribute("aa",123);
//        return "redirect:/user/getName2";
//    }
    @GetMapping("getName3")
    public Map<String,Object> getName3() {
        return new HashMap<>();
    }

    /*
     *  参数绑定
     *
     *
     *
     *
     *
     *
     *
     *
     * ***/

}
